//
//  SubjectViewController.m
//  LimitFree
//
//  Created by lijinghua on 16/2/29.
//  Copyright © 2016年 lijinghua. All rights reserved.
//

#import "SubjectViewController.h"
#import "SubjectModel.h"
#import "SubjectTableViewCell.h"

@interface SubjectViewController ()

@end

@implementation SubjectViewController

- (id)init{
    if (self = [super init]) {
        self.type = kSubjectType;
        self.navigationStyle = LFNavigationTitleStyle;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.tableView.backgroundColor = [UIColor clearColor];
    self.tableView.tableHeaderView = nil;
}


- (void)registTableViewCell{
    UINib *nib = [UINib nibWithNibName:@"SubjectTableViewCell" bundle:nil];
    [self.tableView registerNib:nib forCellReuseIdentifier:@"cellId"];
}

- (NSString*)composeServerUrl{
    //返回降价的服务端的URL
    return [NSString stringWithFormat:kSubjectUrl,self.page];
}

//专题重写解析方法
- (void)parseRespondsData:(id)respondsObject{
    NSArray *subjectArray = [SubjectModel parseRespondsData:respondsObject];
    [self addToDataSource:subjectArray originalObject:respondsObject];
}


#pragma mark - UITableViewDataSource And Delgate

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    SubjectTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId" forIndexPath:indexPath];
    SubjectModel *model = self.appListArray[indexPath.row];
    [cell updateWithModel:model];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 328.0;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
